package top.yokey.learn1;

import android.app.Application;
import android.content.SharedPreferences;

import top.yokey.learn1.view.PullRefreshViewHelper;

public class MyApp extends Application {
    private static MyApp instance = null;
    private boolean isClick = false;
    private SharedPreferences sharedPreferences;
    private SharedPreferences.Editor editor;
    public static MyApp get() { return instance; }
    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        PullRefreshViewHelper.get().init(14);
        PullRefreshViewHelper.get().setColors(getColors(R.color.purple_700), getColors(R.color.teal_700));
        PullRefreshViewHelper.get().setLoadStyle(PullRefreshViewHelper.LOAD_STYLE_CIRCLE);
        PullRefreshViewHelper.get().setLoadColor(getColors(R.color.teal_700));
        PullRefreshViewHelper.get().setLoadText("加载中...");
        PullRefreshViewHelper.get().setEmptyImage(R.mipmap.ic_pull_refresh);
        PullRefreshViewHelper.get().setEmptyColor(getColors(R.color.teal_700));
        PullRefreshViewHelper.get().setEmptyText("暂无数据~");
        PullRefreshViewHelper.get().setErrorImage(R.mipmap.ic_pull_refresh);
        PullRefreshViewHelper.get().setErrorColor(getColors(R.color.teal_700));
        PullRefreshViewHelper.get().setErrorText("加载失败了~");
        //SP数据存储相关代码
        sharedPreferences = getSharedPreferences("test", MODE_PRIVATE);
        editor = sharedPreferences.edit();
    }
    public SharedPreferences getSharedPreferences() {
        return sharedPreferences;
    }
    public SharedPreferences.Editor getEditor() {
        return editor;
    }

    public int getColors(int id) {

        return getResources().getColor(id);

    }

    public boolean isClick() {
        return isClick;
    }

    public void setClick(boolean click) {
        isClick = click;
    }
}
